include layout/header.jade
div.page-content
  div.row
    div.col-md-12
      div.portlet.box.blue
        div.portlet-title
          div.caption 用户管理
        div.portlet-body
          div.portlet-body(style="padding-bottom:10px")
            form#searchForm.form-inline(role="form",action="/admin/user",method="get")
              div.form-group
                input.form-control(type="text",placeholder="用户名",name="username")
              button#searchButton.btn.text-right.btn-success(type="submit") 查询
          //- table#datatable
          table#datatable.table.table-striped.table-bordered.table-hover(data-url="/admin/ajax/user")
            thead
              tr
                th(data-name="username") 用户名
                th(data-name="password") 密码
                th(data-name="email") 邮箱
                th(data-name="company") 公司
                th(data-name="phone") 电话
                th(data-name="active") 操作
script(type='text/javascript').
      aoColumnDefs = [{
                    "mRender": function ( data, type, row ) {
                      if(!data)
                        return "<a class='btn green active' data-id='"+row['_id']+"''>激活</a>"
                      else
                        return "<a class='btn yellow lock' data-id='"+row['_id']+"''>禁用</a>"
                    },
                    "aTargets": [5]
                }];
include layout/footer.jade
script(type='text/javascript').
      $(document).ready(function(){
        $("#datatable").on('click','.active',function(){
            var item = $(this);
            $.get("/user/active?id="+$(this).attr("data-id")).success(function(){
                item.removeClass('green active').addClass('yellow lock').text('禁用');
              })
          });
        $("#datatable").on('click','.lock',function(){
            var item = $(this);
            $.get("/user/lock?id="+$(this).attr("data-id")).success(function(){
                item.removeClass('yellow lock').addClass('green active').text('激活');
              })
          });

      });
